package cn.hx.mall.sell.service.impl;

import cn.hx.mall.sell.dao.SmsFlashPromotionProductRelationDao;
import cn.hx.mall.sell.entity.SmsFlashPromotionProductRelation;
import cn.hx.mall.sell.service.SmsFlashPromotionProductRelationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品限时购与商品关系表(SmsFlashPromotionProductRelation)表服务实现类
 *
 * @author makejava
 * @since 2022-11-02 16:10:29
 */
@Service("smsFlashPromotionProductRelationService")
public class SmsFlashPromotionProductRelationServiceImpl implements SmsFlashPromotionProductRelationService {
    @Resource
    private SmsFlashPromotionProductRelationDao smsFlashPromotionProductRelationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SmsFlashPromotionProductRelation queryById(Long id) {
        return this.smsFlashPromotionProductRelationDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<SmsFlashPromotionProductRelation> queryAllByLimit(int offset, int limit) {
        return this.smsFlashPromotionProductRelationDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param smsFlashPromotionProductRelation 实例对象
     * @return 实例对象
     */
    @Override
    public SmsFlashPromotionProductRelation insert(SmsFlashPromotionProductRelation smsFlashPromotionProductRelation) {
        this.smsFlashPromotionProductRelationDao.insert(smsFlashPromotionProductRelation);
        return smsFlashPromotionProductRelation;
    }

    /**
     * 修改数据
     *
     * @param smsFlashPromotionProductRelation 实例对象
     * @return 实例对象
     */
    @Override
    public SmsFlashPromotionProductRelation update(SmsFlashPromotionProductRelation smsFlashPromotionProductRelation) {
        this.smsFlashPromotionProductRelationDao.update(smsFlashPromotionProductRelation);
        return this.queryById(smsFlashPromotionProductRelation.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.smsFlashPromotionProductRelationDao.deleteById(id) > 0;
    }

    @Override
    public List<SmsFlashPromotionProductRelation> queryAll(SmsFlashPromotionProductRelation flashPromotionProductRelation) {
        return smsFlashPromotionProductRelationDao.queryAll(flashPromotionProductRelation);
    }

    @Override
    public int queryCount(SmsFlashPromotionProductRelation flashProductRelation) {
        return smsFlashPromotionProductRelationDao.queryCount(flashProductRelation);
    }


}